package com.example.gobang_system.service;

import com.example.gobang_system.entity.Userinfo;
import com.example.gobang_system.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2023-05-25
 * Time: 19:38
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 注册
     */
    public Integer register(Userinfo userinfo) {
        return userMapper.reg(userinfo);
    }

    /**
     * 通过名字查询用户(登录)
     */
    public Userinfo getByUserName(String username) {
        return userMapper.getUserByName(username);
    }

    /**
     *  logcount - 1
     */
    public void reduceLogCount(Integer logcount, Integer id) {
        userMapper.reduceLogCount(logcount, id);
    }

    /**
     *  设置状态码
     */
    public void setUserState(Integer state, Integer id) {
        userMapper.setUserState(state, id);
    }

}
